
import time
from socket import *
import os

tcp_client_socket = socket(AF_INET, SOCK_STREAM)
tcp_client_socket.settimeout(1200)
connected = False
while True:
    if not connected:
        try:
            tcp_client_socket.connect(("10.0.0.1", 8890))
            connected = True
        except:
            pass
    else:
        msg = bytearray(32)
        s = time.time()
        for i in range(5000):
            tcp_client_socket.send(msg)

        d = time.time() - s

        print d
        with open('lr5.out', 'a+') as f:
            f.write('%f\n' % d)
        break

